<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">交管员列表</a></li>
        <li><a href="{:url('AdminControll/controll_add')}">添加交管员</a></li>
    </ul>
    <form class="js-ajax-form" action="" method="post">

        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="50">编号ID</th>
                <th>姓名</th>
                <th>头像</th>
                <th>电话</th>
                <th>介绍</th>
                <th>巡逻管控</th>
                <th>问题人/车管控</th>
                <th>隐患路段上报</th>
                <th>状态</th>
                <th width="95">操作</th>
            </tr>
            </thead>

            <foreach name="data" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.name}</td>
                    <td><img src="{$vo.avatar|default='__STATIC__/images/head.png'}" id="pic" width="135" style="cursor: pointer"/></td>
                    <td>{$vo.phone}</td>
                    <td>{$vo.content}</td>
                    <td><input name="patrol" class="change" data-id="{$vo.id}" value="{$vo.patrol}"><span class="add"  data-id="{$vo.id}" data-name="patrol"><svg t="1574920146631" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1901" width="20" height="20"><path d="M902.245376 393.074688l0 235.795456L629.177344 628.870144l0 273.068032-235.79648 0L393.380864 628.870144 120.358912 628.870144 120.358912 393.074688l273.022976 0L393.381888 120.049664l235.79648 0 0 273.025024L902.245376 393.074688z" p-id="1902" fill="#11bca1"></path></svg></span></td>
                    <td><input name="man_car" class="change" data-id="{$vo.id}" value="{$vo.man_car}"><span class="add"  data-id="{$vo.id}" data-name="man_car"><svg t="1574920146631" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1901" width="20" height="20"><path d="M902.245376 393.074688l0 235.795456L629.177344 628.870144l0 273.068032-235.79648 0L393.380864 628.870144 120.358912 628.870144 120.358912 393.074688l273.022976 0L393.381888 120.049664l235.79648 0 0 273.025024L902.245376 393.074688z" p-id="1902" fill="#11bca1"></path></svg></span></td>
                    <td><input name="road" class="change" data-id="{$vo.id}" value="{$vo.road}"><span class="add"  data-id="{$vo.id}" data-name="road"><svg t="1574920146631" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1901" width="20" height="20"><path d="M902.245376 393.074688l0 235.795456L629.177344 628.870144l0 273.068032-235.79648 0L393.380864 628.870144 120.358912 628.870144 120.358912 393.074688l273.022976 0L393.381888 120.049664l235.79648 0 0 273.025024L902.245376 393.074688z" p-id="1902" fill="#11bca1"></path></svg></span></td>

                    <td><if condition="$vo.status==1"><p style="color: yellowgreen"><b>明星交管员</b></p><else/>普通交管员</if></td>
                    <td>

                        <if condition="$vo.status==0">
                            <a class="btn btn-xs btn-primary js-ajax-dialog-btn" href="{:url('AdminControll/talent_add',['id'=>$vo.id])}">加为明星交管员</a>
                        </if>
                        <if condition="$vo.status==1">
                            <a class="btn btn-xs btn-warning js-ajax-dialog-btn" href="{:url('AdminControll/talent_cancel',['id'=>$vo.id])}">撤销明星交管员</a>
                        </if>
                        <a class="btn btn-xs btn-primary" href="{:url('AdminControll/controll_add',['id'=>$vo.id])}">编辑</a><a class="btn btn-xs btn-danger js-ajax-dialog-btn" href="{:url('AdminControll/del',['id'=>$vo.id])}">删除</a>
                    </td>
                </tr>
            </foreach>
        </table>
        <ul class="pagination">{$page|default=''}</ul>
    </form>

</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript" src="/html/layui/layui.js"></script>
<script>
    layui.use(['layer'],function(){
    $( '.change').blur( function(e){
        console.log(e)
       var id=e.target.dataset.id
        var name=e.target.name
        var patrol=e.target.value
        $.ajax({
            type: "post",
            url: "/portal/admin_controll/save_change",
            data:{"id":id,'name':name,"patrol":patrol},
            dataType: "json",
            success: function(res) {
                layer.msg(res.msg)
                console.log(res)
             }
            });
        })

        $('.add').click(function (e) {
            var id=e.currentTarget.dataset.id
            var name=e.currentTarget.dataset.name
            var code = prompt("请输入增加值：");
            var that=$(this)
            if (code!=null && code!="")
            {
                $.ajax({
                    type:"post",
                    url:'/portal/admin_controll/save_add',
                    data:{"id":id,'name':name,'code':code},
                    dataType:"json",
                    success:function(res){
                        layer.msg(res.errmsg)
                        if(!res.error){
                            var input=that.parent().find("input[name="+name+"]")
                            input.val(input.val()*1+code*1)
                        }
                    }
                })
            }
        })

    })




    function reloadPage(win) {
        win.location.reload();
    }


</script>
</body>
</html>